<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<div id="myClassBegin_AAA">
		<table class="table table-striped table-hover table-bordered" style="font-size:14px;font-weight:bold;">
			<tr>
				<td id="sys_Class_1" ></td>
			</tr>
			<tr>
				<td id="sys_LearnPlant_1"></td>
			</tr>
			<tr>
				<td>
					<table class="table table-striped table-hover table-bordered">
						<tr>
							<td>步骤名称</td>
							<td>时长</td>
							<td>内容</td>
							<td>附件</td>
							<td>标签</td>
							<td>场地</td>
							<td>教学器材</td> 
						</tr> 
						<tbody id="learnPlant_cd1">
						
						</tbody>			
					</table>
				</td>
			</tr>
		 </table> 
		 <button class="btn" id="homeWorkFafang">
			<i class="icon-pencil align-top bigger-125"></i>
			发放作业
		</button>
		 <button class="btn" id="homeWorkClosePlant">
			<i class="icon-pencil align-top bigger-125"></i>
			完成上课
		</button>

</div>
<script>
 (function(){ 
	 function loadlearnPlant(){		 
		 var url ="${pageContext.request.contextPath}/edu/sys_LearnPlantAction.do?method=getClassBegin";
		 $.ajax({
		   type: "POST",
		   url: url, 
		   dataType:'json',
		   success: function(msg){
			 if(msg && msg.sys_Class){
				 var sysClass = msg.sys_Class;
				 $("#sys_Class_1").append(sysClass.pName);
				 $("#homeWorkFafang").data("sc",sysClass);	
				 $("#homeWorkClosePlant").data("sc",sysClass);	
			 }
			 if(msg && msg.sys_LearnPlant){
				  var slp = msg.sys_LearnPlant;
				 $("#sys_LearnPlant_1").append(slp.pName);
				 $("#homeWorkFafang").data("pl",slp);	
				 $("#homeWorkClosePlant").data("pl",slp);				 
			 }
			 if(msg && msg.children){
				 var children = msg.children;
				 if(children && children.length>0){ 
					  for(var i=0;i<children.length;i++){
							 	object = children[i]; 
							 	var vt="";
							 	if(object.arrlable){
							 		var arr =object.arrlable;
							 		for(var j=0;j<arr.length;j++){
										if(j==arr.length-1){
											vt+='<button class="btn btn-xs btn-inverse" style="margin-top:4px;" name="lablebuton1" table_id="'+arr[j].table_id+'">'+arr[j].name+'</button>';								 
										}else{
											vt+='<button class="btn btn-xs btn-inverse" style="margin-top:4px;" name="lablebuton1" table_id="'+arr[j].table_id+'">'+arr[j].name+'</button>&nbsp;';
										}
									}
							 	}
								var tr ='<tr name="buzhoutr">'+
						 			'<td>'+object.buzhou1+'</td>'+
						 			'<td>'+object.buzhou2+'</td>'+
						 			'<td>'+object.buzhou5+'</td>'+
						 			'<td>'+object.buzhou4+'</td>'+
						 			'<td>'+vt+'</td>'+
						 			'<td>'+object.buzhou3+'</td>'+
						 			'<td>'+object.buzhou6+'</td>'+ 
						 			'</tr>';
								if($("#learnPlant_cd1").length>0){
									 var  tr1 =$(tr);
									 tr1.data("pl",object); 
									 $("#learnPlant_cd1").append(tr1); 
								}  
						 } 
					 
				 }  
			 }
		   }
		}); 
	 }; 
	 //发放作业
	 $("#homeWorkFafang").click(function(){
		 var pl =$(this).data("pl");
		 var sc =$(this).data("sc");
		 //alert(pl.table_id +"=="+sc.table_id);
		 if(pl&&sc){
		 var url ="${pageContext.request.contextPath}/edu/sys_LearnPlantAction.do?method=updatePlantHomeWork";
		 $.ajax({
		   type: "POST",
		   url: url, 
		   data:{sys_PlantId:pl.table_id,classId:sc.table_id},
		   dataType:'json',
		   success: function(msg){
			  alert(msg.message);
		   }
		}); 
		 }else{
			 alert("没有课程!");
		 }
	 });
	 $("#homeWorkClosePlant").click(function(){
		 
		 var pl =$(this).data("pl");
		 var sc =$(this).data("sc");
		 //alert(pl.table_id +"=="+sc.table_id);
		 if(pl&&sc){
		 var url ="${pageContext.request.contextPath}/edu/sys_LearnPlantAction.do?method=updatePlantMasterClose";
		 $.ajax({
		   type: "POST",
		   url: url, 
		   data:{sys_PlantId:pl.table_id,classId:sc.table_id},
		   dataType:'json',
		   success: function(msg){
			  alert(msg.message);
		   }
		}); 
		 }else{
			 alert("没有课程!");
		 }
	
		
	 });
	 //加载
	 $(function(){
		 loadlearnPlant();
	 });
 })();
</script>